﻿using Cqrs.Infrastructure;
using Meditime.Domain;
using domain = Meditime.Domain;

namespace Meditime.UI
{
    public class StaffMemberCommands
    {
        private static StaffMemberCommandHandlers _commandHandlers;
        static readonly object lockObject = new object();

        private static IRepository<domain.StaffMember> _repository;
        public static IRepository<domain.StaffMember> Repository
        {
            get
            {
                if (_repository == null)
                {
                    _repository = new Repository<domain.StaffMember>(EventStore.Instance());
                }
                return _repository;
            }
        }

        private StaffMemberCommands()
        {
        }

        public static StaffMemberCommandHandlers Instance()
        {
            if (_commandHandlers == null)
            {
                lock (lockObject)
                {
                    _commandHandlers = new StaffMemberCommandHandlers(Repository, EventStore.StaffMemberSmf);
                }
            }
            return _commandHandlers;
        }
    }
}
